# 第一阶段：构建环境（使用与服务器兼容的ARM64基础镜像）
FROM dl-project:noCode as builder

USER root

# 设置工作目录
WORKDIR /app

# 清空旧工作目录
RUN rm -rf /app/*

# 将代码复制到工作目录
COPY --chown=txtdeal:txtdeal . .


RUN export LD_LIBRARY_PATH="/usr/local/openssl/lib:$LD_LIBRARY_PATH"  &&\
    /usr/local/python3.10/bin/python3.10 -m venv prdvenv  &&\
    source prdvenv/bin/activate && \
    pip config set global.index-url https://mirrors.aliyun.com/pypi/simple &&\
    pip config set install.trusted-host mirrors.aliyun.com &&\
    pip install -r requirements-docker.txt



# 测试代码
RUN source prdvenv/bin/activate  &&\
    python3.10 -c "import paddle; import paddleocr; print('paddleocr module loaded successfully')" &&\
    python3.10 -c "import torch; import torchvision" &&\
    python3.10 -c "import ssl; print(ssl.OPENSSL_VERSION)" &&\
    python3.10 -c "import _ctypes; print('ctypes module loaded successfully')"


# todo package
# RUN export LD_LIBRARY_PATH="/usr/local/openssl/lib:$LD_LIBRARY_PATH" && \